package com.wan37.logic.skill.impl;

import com.wan37.logic.skill.AbstractEnemyONESkill;
import com.wan37.protobuf.constant.AllRoleLabel;
import com.wan37.protobuf.constant.CommonBase;
import com.wan37.protobuf.constant.SkillLabel;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : luoyong
 * @date : 2020-06-28 15:24
 **/
@Component(SkillLabel.ONE + SkillLabel.ENEMY + SkillLabel.ORDINARY)
@Scope("prototype")
public class OrdinarySkillEnemy extends AbstractEnemyONESkill {

    @Override
    public Map<String, Map<String, Long>> handle(String sceneI) {
        long allRoleVOANT = allRoleVO.getNumberMap().get(CommonBase.ATN) * skillVO.getNumberMap()
                .get(CommonBase.BUFF_ATN) + skillVO.getNumberMap().get(CommonBase.BUFF_ADD_ATN);

        long allRoleVO2DEF = allRoleVO2.getNumberMap().get(CommonBase.DEF);
        Map<String, Map<String, Long>> allRoleVONumberMap = new HashMap<>();
        long mp = allRoleVO2.getNumberMap().get(CommonBase.MP) - (allRoleVOANT - allRoleVO2DEF);
        Map<String, Long> numberMap = new HashMap<>();
        if (mp < 0) {
            allRoleVO2.getNumberMap().put(CommonBase.MP, (long) 0);
            allRoleVO2.setStatus(AllRoleLabel.STATUS_DIE);
            numberMap.put(CommonBase.MP, (long) 0);
            allRoleVONumberMap.put(allRoleVO2.getAllRoleId(), numberMap);
        } else {
            allRoleVO2.getNumberMap().put(CommonBase.MP, mp);
            numberMap.put(CommonBase.MP, mp);
            allRoleVONumberMap.put(allRoleVO2.getAllRoleId(), numberMap);
        }
        return allRoleVONumberMap;
    }
}
